#! /bin/bash

hive  -S -e  "
--==========访问与咨询宽表========
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.max.dynamic.partitions=100000;
set hive.exec.max.created.files=150000;
--hive压缩
set hive.exec.compress.intermediate=true;
set hive.exec.compress.output=true;
--写入时压缩生效
set hive.exec.orc.compression.strategy=COMPRESSION;

INSERT INTO bxg_dwb.dwb_visitor_wide PARTITION (dt)
select
       a.id,
       a.create_date_time,
       a.session_id,
       a.sid,
       a.create_time,
       a.seo_source,
       a.seo_keywords,
       a.ip,
       a.area,
       a.country,
       a.province,
       a.city,
       a.origin_channel,
       a.`user`,
       a.manual_time,
       a.begin_time,
       a.end_time,
       a.last_customer_msg_time_stamp,
       a.last_agent_msg_time_stamp,
       a.reply_msg_count,
       a.msg_count,
       a.browser_name,
       a.os_info,
       substr(create_time, 1, 13) as year_month_day_hour,
       substr(create_time, 1, 10) as year_month_day,
       substr(create_time, 1, 7) as year_month,
       ceil(month(create_time)/3) as year_quarterinfo,
       substr(create_time, 1, 4) as year,
       b.referrer,
       b.from_url,
       b.landing_page_url,
       b.url_title,
       b.platform_description,
       b.other_params,
       b.history,
       substr(create_time, 1, 10) as dt
from bxg_dwd.ft_web_chat_ems_2019_07 as a
left join bxg_dwd.ft_web_chat_text_ems_2019_07 as b
on a.id = b.id;

"